﻿
using Chain.BLL;
using System;
using System.Data;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class promotions : Page
{


    private DataTable GetList_activity()
    {

        StringBuilder builder = new StringBuilder();
        builder.Append("  select A.id,b.name,b.note,convert(date,b.StartTime,120)StartTime,convert(date,b.EndTime,120)EndTime,isnull(c.nums,0) as Score");
        builder.Append("  ,isnull(d.nums,0) as money,isnull(e.score,0)share_score");
        builder.Append("  ,isnull(e.money,0)share_money,isnull(e.WxPocket,0)share_WxPocket");
        builder.Append("  ,isnull(f.score,0)Extend_score,isnull(f.money,0)Extend_money,isnull(f.WxPocket,0)Extend_WxPocket");
        builder.Append("  ,isnull(g.PresentsName,'')PresentsName,isnull(h.CouponTitle,'')CouponTitle");
        builder.Append("  ,isnull(k.id,0)Rebateid,isnull(k.Level1,0)Level1,isnull(k.Level2,0)Level2,isnull(k.Level3,0)Level3");
        builder.Append("  from");
        builder.Append("  Activity_Gifts as a ");
        builder.Append("  inner join ");
        builder.Append("  (select * from Activity where Status=1) as b");
        builder.Append("  on a.ActivityID=b.ID");
        builder.Append("  left join ");
        builder.Append("  (select * from ScoreMoneyAwards where isdel=0 and status=1) as c");
        builder.Append("  on a.ScoreID = c.ID");
        builder.Append("  left join ");
        builder.Append("  (select * from ScoreMoneyAwards where isdel=0 and status=1) as d");
        builder.Append("  on a.MoneyID = d.ID");
        builder.Append("  left join");
        builder.Append("  (select * from Share_ExtendAwards where status=1 and isdel=0) as e");
        builder.Append("  on a.ShareID = e.id");
        builder.Append("  left join");
        builder.Append("  (select * from Share_ExtendAwards where status=1 and isdel=0)  as f");
        builder.Append("  on a.ExtendID = f.id");
        builder.Append("  left join ");
        builder.Append("  (select * from PresentAwards  where status=1 and isdel=0) as g");
        builder.Append("  on a.PresentID = g.id");
        builder.Append("  left join");
        builder.Append("  (select * from Coupon where status=1 and isdel=0)  as h");
        builder.Append("  on a.TicketID = h.ID");
        builder.Append("  left join");
        builder.Append("  (select * from RebateAwards where status=1 and isdel=0)  as k");
        builder.Append("  on a.RebateID = k.id");
        builder.Append("  where a.isdel=0");

        return Chain.DBUtility.DbHelperSQL.Query(builder.ToString()).Tables[0];

    }
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = GetList_activity();
        this.rptShopList.DataSource = dt;
        this.rptShopList.DataBind();
    }
}


